function cleanArray(actual) {
  const newArray = [];
  for (let i = 0; i < actual.length; i++) {
    if (actual[i]) {
      newArray.push(actual[i]);
    }
  }
  return newArray;
}

function groupBy(arr = [], key) {
  let mapObj = {};
  arr.forEach((item) => {
    let groupKey = item[key] || "default";
    let childrenArray = mapObj[groupKey] || (mapObj[groupKey] = []);
    childrenArray.push(item);
  });
  return mapObj;
}

export default {
  cleanArray,
  groupBy,
};
